// pages/home/sales.js
import { Admin } from '../../model/admin.js';
var admin = new Admin()
var appInst =  getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sale: 0,
    order_count: 0,
    new_user_count: 0,
    hot_pay_count: 0,
    team_user_count: 0,
    store_user_count: 0,
    team_count: 0,
    user_money_sum: 0,
    fission_user_count: 0,
    withdrawal: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中',
    });
    this.getStoreRank();
  },
  getStoreRank() {
    admin.getAdminRank((res) => {
      this.setData({
        hidden: true,
        sale: res.sale,
        order_count: res.order_count,
        new_user_count: res.new_user_count,
        hot_pay_count: res.hot_pay_count,
        // team_user_count: res.team_user_count,
        store_user_count: res.store_user_count,
        // team_count: res.team_count,
        user_money_sum: res.user_money_sum,
        fission_user_count: res.fission_user_count,
        withdrawal: res.withdrawal,
      })
      wx.hideLoading();
    })
  },
  /**
   * 修改title
   */
  onShow:function(){
    if(appInst.globalData.appstorename!='美业团')
      appInst.settitle();
  },
  openSale() {
    wx.navigateTo({
      url: '../store/store'
    })
  },
  openUsermoneysum(){
    wx.navigateTo({
      url:'../admin/user_money'
    })
  },
  openOrderSum() {
    wx.navigateTo({
      url: '../admin/order_list'
    })
  },
  openProductSum() {
    wx.navigateTo({
      url: '../admin/hot'
    })
  },
  openNewUser() {
    wx.navigateTo({
      url: '../admin/new_user'
    })
  },
  openTeamUser() {
    wx.navigateTo({
      url: '../admin/team_user'
    })
  },
  openTeam() {
    wx.navigateTo({
      url: '../admin/team'
    })
  },
  openStoreUser() {
    wx.navigateTo({
      url: '../admin/store_user'
    })
  },
  openFission() {
    wx.navigateTo({
      url: '../admin/fission'
    })
  },
  openWithdrawal() {
    wx.navigateTo({
      url: '../admin/withdrawal'
    })
  },
})